package com.wyf.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.jms.ObjectMessage;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.common.entity.Dept1;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.wyf.dao.DeptDao;
import com.wyf.dao.impl.DeptDaoImpl;

public class DeptServlet extends HttpServlet {
	private DeptDao deptDao; 
	@Override
	public void init() throws ServletException {
		// TODO Auto-generated method stub
		deptDao=new DeptDaoImpl();
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		List<Dept1> list=deptDao.findByCondition(null);
		ObjectMapper mapper=new ObjectMapper();
		String json=mapper.writeValueAsString(list);
		PrintWriter out=resp.getWriter();
		out.print(json);
	}
}
